//
//  tableKYFViewController.m
//  musicPlayer
//
//  Created by adminstrator on 13-8-9.
//  Copyright (c) 2013年 yufeng. All rights reserved.
//

#import "tableKYFViewController.h"
#import "KYFAppDelegate.h"
#import "KYFViewController.h"

@interface tableKYFViewController ()

@end

@implementation tableKYFViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        //self.tabBarItem.title = @"歌曲列表";
        //self.tabBarItem.image = [UIImage imageNamed:@"renwu_sel.png"];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"歌曲列表";
    
    delegate = [[UIApplication sharedApplication]delegate];
    
    CGSize size_screen = [[UIScreen mainScreen]bounds].size;
    
    UISearchBar *searchBar = [[UISearchBar alloc]initWithFra20me:CGRectMake(0, 0, 320, 44)];
    searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    searchDisplayController.searchResultsDataSource = self;
    searchDisplayController.searchResultsDelegate = self;
    self.musicList.tableHeaderView = searchBar;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [_musicList release];
    [super dealloc];
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [delegate.array count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *viewController = @"viewController";
    NSInteger row = [indexPath row];
    UITableViewCell *cell;
    cell = [tableView dequeueReusableCellWithIdentifier:viewController];
    if (cell==nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:viewController];
    }
    cell.textLabel.text = [delegate.array objectAtIndex:row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger row = [indexPath row];
    KYFViewController *mus = [[[KYFViewController alloc]initWithNibName:@"KYFViewController" bundle:nil]autorelease];
    mus.music = [delegate.array objectAtIndex:row];
    mus.myrow = row;
    NSLog(@"%d",mus.myrow);
    mus.hidesBottomBarWhenPushed = YES;       //跳转时隐藏tabBar
    [self.navigationController pushViewController:mus animated:YES];
}


@end
